
{{if empty($parent_info['Menu']['parent_id'])}}
<!-- 加载一个整个菜单的所有项，顶层节点为菜单分类 -->


<?php
global $hookvars;
if(is_array($hookvars['navmenu'])){
	$menus = array_merge($menus,$hookvars['navmenu']);
}
?>
{{loop $menus $key $submenu}}
	<?php
		$submenu_var = 'leftmenu_'.$submenu['Menu']['slug'];
	?>	
	{{if $$submenu_var}}
		{{$$submenu_var}}
	{{else}}
		<?php
			$this->Hook->call('submenu',array(&$submenu)); 
			if(empty($submenu['children'])) continue;
		?>	
		<?PHP if(empty($submenu['Menu']['slug'])){ $submenu['Menu']['slug']=$submenu['Menu']['id']; }?>
		<ul id="leftmenu_{{$submenu['Menu']['slug']}}" {{if $key>0}}style="display:none;"{{/if}} class="leftmenu">
			{{loop $submenu['children'] $key $subitem}}
			<li class="open">
			{{if !empty($subitem['children'])}}
			    <?php echo $this->Html->link(
		    	'<i class="fa fa-lg fa-fw fa-folder"></i> <span class="menu-item-parent">'.$subitem['Menu']['name'].'</span>'
		   		 ,"#submenu_".$subitem['Menu']['id'],
			array(
			'data-toggle'=>"collapse",'data-parent'=>"#leftmenu_".$submenu['Menu']['slug'],'escape'=>false
			)); ?>
					<ul  id="submenu_{{$subitem['Menu']['id']}}" style="display: block; visibility: visible;">
			        {{loop $subitem['children'] $menuitem}}
			        	<?php if($menuitem['Menu']['prefix_icon']){$menuitem['Menu']['name']='<i class="'.$menuitem['Menu']['prefix_icon'].'"></i> '.$menuitem['Menu']['name'];} ?>
			        	<li><?php
			        	if(empty($menuitem['Menu']['link']) && !empty($menuitem['Menu']['model'])) {
							$menuitem['Menu']['link'] = '/admin/'.Inflector::tableize($menuitem['Menu']['model']).'/list?cate_id='.$menuitem['Menu']['id'];
						}
						$options = array('rel'=>$menuitem['Menu']['rel'],'escape'=>false);
						if($menuitem['Menu']['target']) {
							$options['target'] = $menuitem['Menu']['target'];
						}
			        	echo $this->Html->link($menuitem['Menu']['name'],$menuitem['Menu']['link'],$options); ?></li>
			        {{/loop}}
			        </ul>
			 </li>
		    {{else}}
		    	<?php   echo $this->Html->link(
				'<i class="fa fa-lg fa-fw fa-folder"></i> <span class="menu-item-parent">'.$subitem['Menu']['name'].'</span>',
			$subitem['Menu']['link'],array(
					'rel'=>$subitem['Menu']['rel'],'escape'=>false)); ?></li>
		    {{/if}}   
		    {{/loop}}
		</ul>
	{{/if}}
{{/loop}}
{{else}}
<!-- 非顶层节点时，加载菜单一项的所有子菜单项 -->
<li id="leftmenu_{{$parent_id}}" class="leftmenu">
    <?php  foreach($menus as $key => $submenu) { ?>
    
    <?php echo $this->Html->link(
	'<i class="fa fa-lg fa-fw fa-folder"></i> <span class="menu-item-parent">'.$submenu['Menu']['name'].'</span>',
"#submenu_".$submenu['Menu']['id'],
array(
	'data-toggle'=>"collapse",
	'data-parent'=>"#leftmenu_".$parent_id,'escape'=>false
)); ?>
		<ul>
        <?php  foreach($submenu['children'] as $menuitem) { ?>
        <li><?php 
        		if($menuitem['Menu']['prefix_icon']){$menuitem['Menu']['name']='<i class="'.$menuitem['Menu']['prefix_icon'].'"></i> '.$menuitem['Menu']['name'];}
				if(empty($menuitem['Menu']['link']) && !empty($menuitem['Menu']['model'])) {
					$menuitem['Menu']['link'] = '/admin/'.Inflector::tableize($menuitem['Menu']['model']).'/list?cate_id='.$menuitem['Menu']['id'];
				}
        	 	echo $this->Html->link($menuitem['Menu']['name'],$menuitem['Menu']['link'],array('rel'=>$menuitem['Menu']['rel'],'escape'=>false));
        	 ?></li>
         <?php } ?>
        </ul>
    <?php } ?>
</li>
{{/if}}